Initializing the ImageWriter II Environment
QuickDraw GX sends theGXInitialize
message when an application creates a job object, just after the application has called theGXNewJob
function so that your driver can initialize any storage and establish the values of global variables. The ImageWriter II printer driver performs very simple initialization. Its override of theGXInitialize
message,SD_Initialize
, allocates a globals world so that the driver can access the QuickDraw GX globals. TheSD_Initialize
function is shown in Listing 3-4.Listing 3-4 Initializing the ImageWriter II printer driver
OSErr SD_Initialize (void) { SpecGlobalsHdl hGlobals; OSErr anErr; /* create the globals */ hGlobals = (SpecGlobalsHdl) NewHandleClear( sizeof(SpecGlobals) ); anErr = MemError(); /* save the globals */ SetMessageHandlerInstance(hGlobals); /* branch to exception handler if necessary */ nrequire( anErr, MNewHandleClear ); /* no draft table allocated yet */ (**hGlobals).draftTable = nil; return(noErr); MNewHandleClear: return(anErr); }TheSD_Initialize
function first allocates the QuickDraw GX message globals. Then it initializes the global handle to the draft table tonil
because this table, which is used for drawing draft-quality characters on the printing device, is only needed when the ImageWriter II is printing in draft mode.You almost always override the
GXInitialize
message for a driver. No matter which imaging system your driver is written for, you need to initialize the QuickDraw GX message globals. ThGXInitialize
message is described on page 4-43 in the chapter "Printing Messages."
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help